home *** CD-ROM | disk | FTP | other *** search
/ Fritz: All Fritz / All Fritz.zip / All Fritz / FILES / PROGASIC / BASFILES.LZH / GETDIRS.BAS < prev    next >
BASIC Source File  |  1988-09-10  |  1KB  |  73 lines

  1. '$INCLUDE:'QBTOOLS.INC'
  2. '' '$INCLUDE: 'qbtools2.inc'
  3.  
  4. 'DIM Dirs$(500)
  5. 'CLS
  6. 'PRINT "Please Wait .... Reading Directories.  ";
  7. '
  8. 'GetDirectories Dirs$(), Dc%
  9. 'QuickSort Dirs$(), Dc%
  10. '
  11. 'PRINT Dc%; "Found"
  12. '
  13. 'FOR j% = 1 TO Dc%
  14. '   PRINT Dirs$(j%)
  15. 'NEXT j%
  16. '
  17. 'END
  18.  
  19. SUB GetDirectories (DirNames$(), DirCount%)
  20.  
  21.     DIM Temp$(255)
  22.  
  23.     DirPad$ = "\"
  24.     DirNames$(1) = DirPad$
  25.     DirCount% = 1
  26.     CurCount% = 0
  27.  
  28.     WHILE CurCount% < DirCount%
  29.       
  30.         CurCount% = CurCount% + 1
  31.       
  32.         DirPad$ = DirNames$(CurCount%)
  33.       
  34.         IF LEFT$(DirPad$, 1) <> "\" THEN
  35.             DirPad$ = "\" + DirPad$
  36.         END IF
  37.  
  38.         TestName$ = STRING$(8, "?") + "." + STRING$(3, "?")
  39.         ReturnValue$ = STRING$(12, 32)
  40.  
  41.         Attr% = &H10
  42.  
  43.         TempDir$ = DirPad$
  44.         IF RIGHT$(TempDir$, 1) <> "\" THEN
  45.             TempDir$ = TempDir$ + "\"
  46.         END IF
  47.       
  48.         GetMatch Temp$(), TCount%, TempDir$ + "????????", "???", &H10
  49.  
  50.         FOR j% = 1 TO TCount%
  51.             Test$ = Temp$(j%)
  52.             Trim Test$
  53.  
  54.             IF Test$ = "." OR Test$ = ".." THEN
  55.                 Ignore% = 1
  56.             ELSE
  57.                 DirCount% = DirCount% + 1
  58.                 IF RIGHT$(DirPad$, 1) <> "\" THEN
  59.                     Test$ = "\" + Test$
  60.                 END IF
  61.                 IF DirCount% > UBOUND(DirNames$, 1) THEN
  62.                     DirCount% = -DirCount%
  63.                     EXIT SUB
  64.                 END IF
  65.               
  66.                 DirNames$(DirCount%) = DirPad$ + Test$
  67.             END IF
  68.         NEXT j%
  69.     WEND
  70.  
  71. END SUB
  72.  
  73.